#ifndef __TEXT_EDIT_MGR_H__
#define __TEXT_EDIT_MGR_H__

#include "ttcodeTextEdit.h"
#include "tinyxml/tinyxml.h"

class TextEditCtrl;

#include <string>
#include <map>
typedef std::map<std::string ,TextEditCtrl* > TextEditCtrlMgr;
typedef std::map<std::string ,TextEditCtrl* > ExternalFileMgr;


class TextEditMgr : public PanelTextEdit
{
public:
	TextEditMgr( wxWindow* parent)
	:PanelTextEdit(parent)
	{}
	~TextEditMgr(){}
	void reloadProject( void );
	void tryOpenFile(TiXmlElement* elem);
	void tryCloseFile(TiXmlElement* elem);

	// open & close file not in project
	void tryOpenExternalFile(const std::string &filepath);
	void tryCloseExternalFile(const std::string &filepath);
	// let current text to goto line and col
	void tryGotoPos(int line,int col,const std::string &info);

protected:
	// Virtual event handlers, overide them in your derived class
	virtual void m_auinotebookTextEditOnAuiNotebookPageClose( wxAuiNotebookEvent& event );

	TextEditCtrlMgr m_EditMgr;
	ExternalFileMgr m_ExtFileMgr;
};



class TextEditTipsMgr : public PanelEditorTipsCtrl
{
public:
	TextEditTipsMgr( wxWindow* parent)
	:PanelEditorTipsCtrl(parent)
	{}
	~TextEditTipsMgr(){}
protected:
};


#include <wx/stc/stc.h>
#include <string>


class TextEditCtrl: public wxStyledTextCtrl
{
friend class TextEditMgr;
public:
    TextEditCtrl( wxAuiNotebook *parent,TiXmlElement* elem);
	TextEditCtrl( wxAuiNotebook *parent,const std::string &path);
	TiXmlElement* getElement( void ) const { return m_Elem ;}
	std::string getPath( void ) const { return m_Path ;}

private:
	void loadTextStyle(void);
	void loadTextFile(void);

	void loadLogInfo(void);
	void reportInfo(const std::string &info,const std::string &tip);
private:
	TiXmlElement* m_Elem;
	std::string m_Path;
	std::string m_Lang;
	wxBitmap m_ErrorMark;
	wxBitmap m_WarningMark;
	wxBitmap m_NoteMark;

	DECLARE_EVENT_TABLE();
};


#endif // __TEXT_EDIT_MGR_H__
